import 'package:flutter/material.dart';
import 'package:flutter_app/model/tweet.dart';

import 'package:flutter_app/style/color.dart';
import 'package:flutter_app/tools/utils.dart';
import 'package:flutter_app/view/tweet/menu_build.dart';

class ReplyItem extends StatefulWidget {
  ReplyItem({this.reply, key}) : super(key: key);
  final Reply reply;

  @override
  _ReplyItemState createState() => _ReplyItemState();
}

class _ReplyItemState extends State<ReplyItem> {
  _ReplyItemState();

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          //回复头部
          Row(
            children: [
              //用户名和发布时间
              Padding(
                  padding: EdgeInsets.fromLTRB(20, 10, 10, 10),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Padding(
                        padding: EdgeInsets.all(.0),
                        child: new Text(
                          widget.reply.userName,
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          style: TextStyle(
                            fontSize: 14.0,
                            height: 1.2,
                          ),
                        ),
                      ),
                      Padding(
                          padding: EdgeInsets.all(.0),
                          child: new Text(
                            m_utils.timeDifferenceToNow(
                                widget.reply.inTime, DateTime.now()),
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(
                              color: m_color.grey,
                              fontSize: 12.0,
                              height: 1.2,
                            ),
                          ))
                    ],
                  )),

              //赞和踩
              Expanded(child: SizedBox()),
              Container(
                  alignment: Alignment.centerRight,
                  child: menuWidget(widget.reply, iconSize: 16.0))
            ],
          ),

          //回复内容
          Container(
            alignment: Alignment.centerLeft,
            child: Padding(
                padding: EdgeInsets.fromLTRB(20, 0, 20, 10),
                child: Text(
                  widget.reply.text,
                )),
          )
        ],
      ),
    );
  }
}
